const webpack = require('webpack')
var TerserPlugin = require('terser-webpack-plugin')
export default {
  // Global page headers (https://go.nuxtjs.dev/config-head)
  head: {
    // title: '网校',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: '' },
    ],
    script:[
      { src: 'https://cdn.polyfill.io/v2/polyfill.min.js' },
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.jpg' }
    ]
  },
  router:{
    extendRoutes (routes, resolve) {
      routes.push(
      {
        name: 'shijuan',
        path: '/shijuan',
        meta:{
          title:"试卷详情",
          sort:"",
          isLogin:true
        },
        component: resolve(__dirname, 'pages/person/shijuan.vue'),
      },
      {
        name: 'testVideo',
        path: '/testVideo',
        meta:{
          title:"测试",
          sort:"",
          isLogin:true
        },
        component: resolve(__dirname, 'pages/person/testVideo.vue'),
      },
      {
        name: 'resultForAdmin',
        path: '/resultForAdmin',
        meta:{
          title:"测试结果",
          isLogin:false
        },
        component: resolve(__dirname, 'pages/content/resultForAdmin.vue'),
      },
      {
        name: 'dbcourser',
        path: '/dbcourse/:id',
        meta:{
          title:"课程详情",
          sort:"",
          isLogin:true
        },
        component: resolve(__dirname, 'pages/person/dbcourse.vue'),
      },
      {
        name: 'result1',
        path: '/result1/:id/:courseId',
        meta:{
          title:"测试结果",
          isLogin:true
        },
        component: resolve(__dirname, 'pages/content/result1.vue'),
      },
        {
          name: 'center',
          path: '/center',
          meta:{
            title:"个人中心",
            sort:"",
            isLogin:true
          },
          component: resolve(__dirname, 'pages/center.vue'),
          children:[
            {
              name: 'home',
              path: '/home',
              meta:{
                title:"个人中心首页",
                sort:"",
                isLogin:true
              },
              component: resolve(__dirname, 'pages/person/home.vue'),
            },
            {
              name: 'result',
              path: '/result',
              meta:{
                title:"测试结果",
                isLogin:true
              },
              component: resolve(__dirname, 'pages/content/result.vue'),
            },
            {
              name: 'signUp',
              path: '/signUp',
              meta:{
                title:"考试报名",
                sort:"",
                isLogin:true
              },
              component: resolve(__dirname, 'pages/person/signUp.vue'),
            },
            {
              name: 'signuppage',
              path: '/signuppage',
              meta:{
                title:"考试报名",
                sort:"",
                isLogin:true
              },
              component: resolve(__dirname, 'pages/person/signuppage.vue'),
            },

            // {
            //   name: 'mocks',
            //   path: '/mocks',
            //   meta:{
            //     title:"模拟考试",
            //     sort:"",
            //     isLogin:true
            //   },
            //   component: resolve(__dirname, 'pages/person/mocks.vue'),
            // },
            {
              name: 'exams',
              path: '/exams',
              meta:{
                title:"正式考试",
                sort:"",
                isLogin:true
              },
              component: resolve(__dirname, 'pages/person/exams.vue'),
            },
            {
              name: 'mockTest',
              path: '/mockTest',
              meta:{
                title:"模拟练习",
                sort:"",
                isLogin:true
              },
              component: resolve(__dirname, 'pages/person/mockTest.vue'),
            },
            {
              name: 'gonggao2',
              path: '/gonggao2',
              meta:{
                title:"公告",
                sort:"",
              },
              component: resolve(__dirname, 'pages/main/gonggao2.vue'),
            },
            {
              name: 'gonggaolan',
              path: '/gonggaolan/:id',
              meta:{
                title:"公告",
                sort:"",
                isLogin:true
              },
              component: resolve(__dirname, 'pages/person/gonggaolan.vue'),
            },
            {
              name: 'inquireScore',
              path: '/inquireScore',
              meta:{
                title:"查看成绩",
                sort:"",
                isLogin:true
              },
              component: resolve(__dirname, 'pages/person/inquireScore.vue'),
            },
            {
              name: 'data',
              path: '/data',
              meta:{
                title:"个人资料",
                sort:"",
                isLogin:true
              },
              component: resolve(__dirname, 'pages/person/data.vue'),
            },
            {
              name: 'password',
              path: '/password',
              meta:{
                title:"修改密码",
                sort:"",
                isLogin:true
              },
              component: resolve(__dirname, 'pages/person/password.vue'),
            },
            {
              name: 'edit_data',
              path: '/edit_data',
              meta:{
                title:"修改资料",
                sort:"",
                isLogin:true
              },
              component: resolve(__dirname, 'pages/person/editData.vue'),
            },
            {
              name: 'course_center',
              path: '/course_center',
              meta:{
                title:"课程中心",
                sort:"",
                isLogin:true
              },
              component: resolve(__dirname, 'pages/person/course.vue'),
            },
            {
              name: 'train',
              path: '/train',
              meta:{
                title:"培训计划",
                sort:"",
                isLogin:true
              },
              component: resolve(__dirname, 'pages/person/plan.vue'),
            },
            {
              name: 'certificate',
              path: '/certificate',
              meta:{
                title:"我的证书",
                sort:"",
                isLogin:true
              },
              component: resolve(__dirname, 'pages/person/certificate.vue'),
            },
            {
              name: 'certificate_details',
              path: '/certificate_details',
              meta:{
                title:"查看证书",
                sort:"",
                isLogin:true
              },
              component: resolve(__dirname, 'pages/person/certificate_details.vue'),
            },
            {
              name: 'collection',
              path: '/collection',
              meta:{
                title:"我的收藏",
                sort:"",
                isLogin:true
              },
              component: resolve(__dirname, 'pages/person/collection.vue'),
            },
            {
              name: 'courseCenter',
              path: '/courseCenter/:id',
              meta:{
                title:"我的课程",
                sort:"",
                isLogin:true
              },
              component: resolve(__dirname, 'pages/person/courseCenter.vue'),
            },
            {
              name: 'mycourse',
              path: '/mycourse',
              meta:{
                title:"我的课程",
                sort:"",
                isLogin:true
              },
              component: resolve(__dirname, 'pages/person/mycourse.vue'),
            },
            {
              name: 'my_help',
              path: '/my_help',
              meta:{
                title:"个人帮助中心",
                sort:"",
                isLogin:true
              },
              component: resolve(__dirname, 'pages/person/myhelp.vue'),
            },
            {
              name: 'archives',
              path: '/archives',
              meta:{
                title:"学习档案",
                sort:"",
                isLogin:true
              },
              component: resolve(__dirname, 'pages/person/archives.vue'),
            },
          ]
        },
        {
          name: 'play',
          path: '/play/:id/:id1',
          meta:{
            title:"观看课程",
            sort:"",
            isLogin:true
          },
          component: resolve(__dirname, 'pages/movie.vue'),
        },
        {
          name: 'ppt_course',
          path: '/ppt_course/:id/:detailId',
          meta:{
            title:"观看课程",
            sort:"",
            isLogin:true
          },
          component: resolve(__dirname, 'pages/pCourse.vue'),
        },
        {
          name: 'live',
          path: '/live/:id',
          meta:{
            title:"观看直播",
            sort:"",
            isLogin:true
          },
          component: resolve(__dirname, 'pages/live.vue'),
        },
        {
          name: 'play1',
          path: '/play1',
          meta:{
            title:"观看课程1",
            sort:"",
            isLogin:true
          },
          component: resolve(__dirname, 'pages/movie1.vue'),
        },
        {
          name: 'login',
          path: '/login',
          meta:{
            title:"登录",
            sort:"",
          },
          component: resolve(__dirname, 'pages/login/login.vue'),
        },
        {
          name: 'code',
          path: '/code',
          meta:{
            title:"",
            sort:"",
          },
          component: resolve(__dirname, 'pages/code.vue'),
        },
        {
          name: 'ceshi',
          path: '/ceshi/:id',
          meta:{
            title:"测试",
            sort:"",
            isLogin:true
          },
          component: resolve(__dirname, 'pages/content/ceshi.vue'),
        },
        {
          name: '',
          path: '/',
          // meta:{
          //   title:"首页",
          //   sort:"",
          // },
          // redirect:'index',
          component: resolve(__dirname, 'pages/index.vue'),
          children:[
            {
              name: 'index',
              path: '/index',
              meta:{
                title:"首页",
                sort:0
              },
              component: resolve(__dirname, 'pages/main/main.vue'),
            },
            {
              name: 'gonggao',
              path: '/gonggao',
              meta:{
                title:"公告",
                sort:"",
              },
              component: resolve(__dirname, 'pages/main/gonggao.vue'),
            },
            {
              name: 'dbcourse',
              path: '/dbcourse',
              meta:{
                title:"点播课程",
                sort:"",
              },
              component: resolve(__dirname, 'pages/main/course.vue'),
            },
            {
              name: 'ppt',
              path: '/ppt',
              meta:{
                title:"PPT课程",
                sort:"",
              },
              component: resolve(__dirname, 'pages/main/ppt.vue'),
            },
            {
              name: '/allCourse',
              path: '/allCourse',
              meta:{
                title:"全部课程",
                sort:"",
              },
              component: resolve(__dirname, 'pages/main/allCourse.vue'),
            },
            {
              name: 'searchList',
              path: '/searchList',
              meta:{
                title:"搜索列表",
                sort:"",
              },
              component: resolve(__dirname, 'pages/main/searchList.vue'),
            },
            {
              name: 'face_course',
              path: '/face_course',
              meta:{
                title:"面授课程",
                sort:"",
              },
              component: resolve(__dirname, 'pages/main/face.vue'),
            },
            {
              name: 'news',
              path: '/news',
              meta:{
                title:"新闻资讯",
                sort:"",
              },
              component: resolve(__dirname, 'pages/main/news.vue'),
            },
            {
              name: 'helpContent',
              path: '/helpContent/:id',
              meta:{
                title:"帮助中心详情",
                sort:"",
              },
              component: resolve(__dirname, 'pages/content/news/helpContent.vue'),
            },
            {
              name: 'indexNewsContent',
              path: '/indexNewsContent/:id',
              meta:{
                title:"头条详情",
                sort:"",
              },
              component: resolve(__dirname, 'pages/content/news/indexNewsContent.vue'),
            },
            {
              name: 'newsContent',
              path: '/newsContent/:id',
              meta:{
                title:"公告详情",
                sort:"",
              },
              component: resolve(__dirname, 'pages/content/news/newsContent.vue'),
            },
            {
              name: 'noticeContent',
              path: '/noticeContent/:id',
              meta:{
                title:"新闻详情",
                sort:"",
              },
              component: resolve(__dirname, 'pages/content/news/noticeContent.vue'),
            },
            {
              name: 'trainNewsContent',
              path: '/trainNewsContent/:id',
              meta:{
                title:"新闻详情",
                sort:"",
              },
              component: resolve(__dirname, 'pages/content/news/trainNewsContent.vue'),
            },
            {
              name: 'help',
              path: '/help',
              meta:{
                title:"帮助中心",
                sort:"",
              },
              component: resolve(__dirname, 'pages/main/help.vue'),
            },
            {
              name: 'paper',
              path: '/paper/:id1/:id2/:id3',
              meta:{
                title:"测试",
                sort:"",
                isLogin:true
              },
              component: resolve(__dirname, 'pages/content/paper.vue'),
            },
            {
              name: 'helpContent',
              path: '/help_content/:id',
              meta:{
                title:"详情",
                sort:"",
              },
              component: resolve(__dirname, 'pages/content/helpContent.vue'),
            },
            {
              name: 'meal',
              path: '/meal_course',
              meta:{
                title:"套餐课程",
                sort:"",
              },
              component: resolve(__dirname, 'pages/main/meal.vue'),
            },
            {
              name: 'order',
              path: '/order/:id',
              meta:{
                title:"订单",
                sort:"",
                isLogin:true
              },
              component: resolve(__dirname, 'pages/content/order.vue'),
            },
            {
              name: 'courserContent',
              path: '/dbcourse_content/:id',
              meta:{
                title:"课程详情",
                sort:"",
              },
              component: resolve(__dirname, 'pages/content/courseContent.vue'),
            },
            {
              name: 'about',
              path: '/about',
              meta:{
                title:"关于我们",
                sort:""
              },
              component: resolve(__dirname, 'pages/main/about.vue'),
            },
            {
              name: 'reg',
              path: '/reg',
              meta:{
                title:"注册",
                sort:""
              },
              component: resolve(__dirname, 'pages/login/reg.vue'),
            },
            {
              name: 'forget',
              path: '/forget',
              meta:{
                title:"找回密码",
                sort:""
              },
              component: resolve(__dirname, 'pages/login/back.vue'),
            }
          ]
        },
      )
    }
  },
  // Global CSS (https://go.nuxtjs.dev/config-css)
  css: [
    'element-ui/lib/theme-chalk/index.css',
     "swiper/swiper-bundle.css"

    /**
     * 配置全局 css
     */

  ],

  // Plugins to run before rendering page (https://go.nuxtjs.dev/config-plugins)
  plugins: [
    '@/plugins/element-ui',
    //'@/plugins/core',
    {src:'@/plugins/axios',ssr:true},
    {src:'@/plugins/route',ssr:true},
    { src: '@/plugins/babel-polyfill', ssr: true },
    { src: '@/plugins/swiper.js', ssr: false },
    { src: '@/plugins/player.js', ssr: false },
    { src: '@/plugins/aliyun-webrtc-sdk.js', ssr: false },
    { src: '@/plugins/gl.js', ssr: false },
  ],

  // Auto import components (https://go.nuxtjs.dev/config-components)
  components: true,

  // Modules for dev and build (recommended) (https://go.nuxtjs.dev/config-modules)
  buildModules: [
  ],

  // Modules (https://go.nuxtjs.dev/config-modules)
  modules: [
    '@nuxtjs/axios',
  ],

  // Build Configuration (https://go.nuxtjs.dev/config-build)
  build: {
    transpile: [/^element-ui/,'installComponents'],
    plugins: [
      new webpack.ProvidePlugin({
        '$': 'jquery'
      }),
    ],
    extend(config, ctx) {
      if(!ctx.isDev&&ctx.isClient){
        config.plugins.push(
          new TerserPlugin({
            terserOptions: {
              compress: {
                drop_console: true,
                drop_debugger:true
              },
            }
          })
        )
      }
      // config.module.rules.push({
      //       test: /\.(png|jpe?g|gif|svg|webp|hdr)(\?.*)?$/,
      //       loader: 'file-loader',
      //       options: {
      //         name: 'img/[name].[ext]'
      //       }
      //     },
      //     {
      //       test: /\.(hdr)$/i,
      //       use: [
      //         {
      //           loader: 'file-loader',
      //           options: {
      //             name: 'img/[name].[ext]'
      //           }
      //         }
      //       ]
      //     })
    }
  }
}
